<layout name='layout' />

<div class="admin-main">
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		<legend>编辑</legend>
	</fieldset>

	<form id="ajaxForm" class="layui-form" method="post" action="<{:U('Ad/edit')}>">
		<div class="layui-form-item">
			<label class="layui-form-label">名称</label>
			<div class="layui-input-block">
				<input type="text" name="name" value="<{$list['name']}>" lay-verify="required" placeholder="请输入广告名称" class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">分类</label>
			<div class="layui-input-block">
				<select name="cid" id="cid" lay-verify="required">
		    	<option value="">==请选择==</option>
		        <volist name="cate" id="vo">
		        <option value="<{$vo['id']}>,<{$vo['path']}>"><php>
		            for($i=0; $i<$vo['count']*2; $i++){
		               echo '&nbsp;&nbsp;';            
		            }
		        </php><{$vo['name']}></option>
		        </volist>
		        </select>
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">广告内容</label>
			<div class="layui-input-block">
				<div class="layui-tab">
					<ul class="layui-tab-title">
						<li <php>if($list['style']==='1')echo 'class="layui-this"';</php> type="1">图片</li>
						<li <php>if($list['style']==='2')echo 'class="layui-this"';</php> type="2">flash</li>
						<li <php>if($list['style']==='3')echo 'class="layui-this"';</php> type="3">文字</li>
						<li <php>if($list['style']==='4')echo 'class="layui-this"';</php> type="4">代码</li>
					</ul>
					<div class="layui-tab-content">
						<div class="layui-tab-item <php>if($list['style']==='1')echo 'layui-show';</php>">
							<div class="layui-form-item">
								<label class="layui-form-label">图片地址</label>
								<div class="layui-input-inline" style="width:400px">
									<input type="text" id="image_url" name="imageUrl" value="<{$list['imageUrl']}>" class="layui-input">
								</div>
								<div class="layui-inline">
									<input type="button" value="上传" class="layui-btn" onclick="uploadfile('<{:U('Upload/image',array('water'=>no,'thumb'=>no))}>','image');"/>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">链接地址</label>
								<div class="layui-input-block">
									<input type="text" name="imageLink" lay-verify="_url" value="<{$list['imageLink']}>" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">图片宽度</label>
								<div class="layui-input-inline">
									<input type="text" name="imageWidth" value="<{$list['imageWidth']}>" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">图片高度</label>
								<div class="layui-input-inline">
									<input type="text" name="imageHeight" value="<{$list['imageHeight']}>" class="layui-input">
								</div>
							</div>
						</div>
						<div class="layui-tab-item <php>if($list['style']==='2')echo 'layui-show';</php>">
							<div class="layui-form-item">
								<label class="layui-form-label">flash地址</label>
								<div class="layui-input-inline" style="width:400px">
									<input type="text" id="flash_url" name="flashUrl" value="<{$list['flashUrl']}>" class="layui-input">
								</div>
								<div class="layui-inline">
									<input type="button" value="上传" class="layui-btn" onclick="uploadfile('<{:U('Upload/image')}>','flash');"/>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">链接地址</label>
								<div class="layui-input-block">
									<input type="text" name="flashLink" value="<{$list['flashLink']}>" lay-verify="_url" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">flash宽度</label>
								<div class="layui-input-inline">
									<input type="text" name="flashWidth" value="<{$list['flashWidth']}>" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">flash高度</label>
								<div class="layui-input-inline">
									<input type="text" name="flashHeight" value="<{$list['flashHeight']}>" class="layui-input">
								</div>
							</div>
						</div>
						<div class="layui-tab-item">
							<div class="layui-form-item <php>if($list['style']==='3')echo 'layui-show';</php>">
								<label class="layui-form-label">文字内容</label>
								<div class="layui-input-block">
									<input type="text" name="text" value="<{$list['text']}>" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">文字链接</label>
								<div class="layui-input-block">
									<input type="text" name="link" value="<{$list['link']}>" lay-verify="_url" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">文字颜色</label>
								<div class="layui-input-inline">
									<input type="text" name="color" value="<{$list['color']}>" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux">如：#ff0000,red</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">文字大小</label>
								<div class="layui-input-inline">
									<input type="text" name="size" value="<{$list['size']}>" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux">如：12px、14px等</div>
							</div>
						</div>
						<div class="layui-tab-item <php>if($list['style']==='4')echo 'layui-show';</php>">
							<div class="layui-form-item">
								<label class="layui-form-label">HTML代码</label>
								<div class="layui-input-block">
									<textarea name="htmlcode" class="layui-textarea"><{$list.htmlcode}></textarea>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>	

		<div class="layui-form-item">
			<label class="layui-form-label">排序</label>
			<div class="layui-input-block">
				<input type="text" name="sort" id="sort" value="<{$list['sort']}>" class="layui-input">
			</div>
		</div>
	
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
				<button type="button" class="layui-btn layui-btn-primary" onclick="window.history.go(-1)">返回</button>
			</div>
		</div>
		<input type="hidden" name="style" id="style" value="<{$list['style']}>" />
		<input type="hidden" name="id" value="<{$list['id']}>" />
	</form>
</div>
<!--上传文件-->
<form style="display:none;" id='myupload' action="" method='post' enctype='multipart/form-data'>
<input id="fileupload" type="file" name="file">
</form>
<div id="uploading" style="display:none;">
	<div class="wrapper">
		<div class="load-bar">   
			<div class="load-bar-inner" data-loading="0"> <span id="counter">0%</span> </div> 
		</div>  
		<p>请等待... </p>
	</div>
</div>
<script type="text/javascript">
$("#cid").val("<{$list['cid']}>,<{$list['path']}>");
$(document).ready(function(){
	$('.layui-tab-title li').click(function(){
		$("#style").val($(this).attr('type'));
	})
})
</script>